package com.api.listener;

import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
*  @Description RabbitMQ监听回调
*  @author Rick Jen
*  @Date   2020/12/3 17:17
*/
@Component
@RabbitListener(queues = "payNotify")
@Slf4j
public class PayMsgListener {


	@RabbitHandler
	public void process(String msg) {
		log.info("【接收到消息】=> {}", msg);

		PayInfo payInfo = new Gson().fromJson(msg, PayInfo.class);
		if (payInfo.getPlatformStatus().equals(PayStatusConstant.PAID)) {
			//修改订单里的状态
			System.out.println("已回调!");
		}
	}
}
